
import { createRoot, Root, } from 'react-dom/client'
import App from './main'
import '../style/reset.css'
import actions from './actions'

const win: any = window
if (!win.__POWERED_BY_QIANKUN__) {
    const dom: any = document.getElementById('root')

    const app: Root = createRoot(dom)
    app.render(<App />)
}



export function bootstrap() {
    return Promise.resolve()
}
let app: Root
export function mount(props: any) {
    if (props) {
        actions.setActions(props)
        props.setGlobalState({
            type: 'formStyle',
            formStyle: {
                width: '100%',
                height: 'calc(100% - 81px)',
                position: 'relative'
            }
        })
    }

    const dom: any = props.container ? props.container.querySelector('#root') : document.getElementById('root')
    app = createRoot(dom)
    app.render(<App />)
}

export function unmount(props: any) {
    props.setGlobalState({
        type: 'formStyle',
        formStyle: {}
    })
    app.unmount()
}

export function update() {
    console.log('update')
}